<script type="text/javascript">
{literal}
$(document).ready(function(){
    $('table#medTbl tr:even').addClass('alt');
});
{/literal}    
</script>
<table id="medTbl" class="grid" style='width: 100%; margin-bottom: 10px;' cellpadding="0" cellspacing="0">
    <caption>{translate}LIST OF MEDICINES{/translate}</caption>
    <thead>
        <tr>
            <th width="30px">{translate}No.{/translate}</th>
            <th width="80px">{translate}Issue date{/translate}</th>
            <th>{translate}Medicine name{/translate}</th>
            <th style='width: 80px'>{translate}Quantity{/translate}</th>
            <th width="80px">{translate}Price{/translate}</th>
            <th width="80px">{translate}Insurance payment{/translate}</th>
            <th width="80px">{translate}Patient payment_1{/translate}</th>
            <th width="120px">{translate}Issue person{/translate}</th>
            <th width="120px">{translate}Doctor{/translate}</th>
        </tr>
    </thead>
    <tbody>
    {if !empty($medicineList)}
    {php} $total    =   array('originalPrice' => 0,'patientPrice' => 0, 'insurancePrice' => 0);{/php}
    {foreach from=$medicineList item=medicine}
        <tr>
            <td>{$medIndex++}</td>
            <td>{$medicine.issue_date}</td>
            <td>{$medicine.medicine_name}</td>
            <td>{$medicine.quantity_num} {$medicine.quantity_title}</td>
             {php}
                $medicine = $this->get_template_vars('medicine');
                 $total['originalPrice'] += $medicine['original_price'];
                $total['insurancePrice'] += $medicine['insurance_price'];
                $total['patientPrice'] += $medicine['patient_price'];
                $col    =   '';
                $col    .=  '<td>' . L10nHelper::renderCurrency($medicine['original_price']) .'</td>';
                $col    .=  '<td>' . L10nHelper::renderCurrency($medicine['insurance_price']) .'</td>';
                $col    .=  '<td>' . L10nHelper::renderCurrency($medicine['patient_price']) .'</td>';
                echo $col;
            {/php}
            <td>{$medicine.issue_person_name}</td>
            <td>{$medicine.doctor}</td>
        </tr>
    {/foreach}
    {php}
        $totalRow   =   '';
        $totalRow    .=  '<tr class="last">
            <td colspan="4" align="right"><span style="color: red; font-weight: bold">'. L10nHelper::_("Total"). '</span></td>
            <td><span style="color: red; font-weight: bold">' . L10nHelper::renderCurrency($total["originalPrice"]) . '</span></td>
            <td><span style="color: red; font-weight: bold">' . L10nHelper::renderCurrency($total["insurancePrice"]) . '</span></td>
            <td><span style="color: red; font-weight: bold">'. L10nHelper::renderCurrency($total["patientPrice"]) . '</span></td>
            <td colspan="2">&nbsp;</td>
            </tr>';
        echo $totalRow;
    {/php}
    {else}
        <tr class='last'><td colspan="9" class="first last">{translate}There is no information on medicine the patient has used{/translate}</td>
    {/if}
    </tbody>
</table>